package adapter.testpaper;

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import application.App;
import bean.LoreBean;
import bean.VersionBean;
import student.andlei.com.student.R;

public class PopupVersionAndLoreAdapter extends BaseQuickAdapter<VersionAndLoreBean, BaseViewHolder> {
    private final int color;
    private VersionBean versonBean;
    private List<LoreBean> loreBean;

    public PopupVersionAndLoreAdapter(int layoutResId, @Nullable List<VersionAndLoreBean> data) {
        super(layoutResId, data);
        color = App.getInstance().getResources().getColor(R.color.color_light_gray);
    }

    public void setSaveTag(VersionBean versonBean, List<LoreBean> loreBean) {
        this.versonBean = versonBean;
        this.loreBean = loreBean;
    }

    @Override
    protected void convert(BaseViewHolder helper, VersionAndLoreBean item) {

        View viewBg = helper.getView(R.id.rl_last_layer_chapter_dialog);
        View viewImage = helper.getView(R.id.iv_last_layer_chapter_dialog);
        int version_id = item.getVersion_id();
        int lore_id = item.getLore_id();
        if (version_id > 0) {
            viewImage.setVisibility(View.INVISIBLE);
            helper.setText(R.id.tv_last_layer_chapter_dialog, item.getVersion_name());
            if (item.isSelect_version_id) {
                viewBg.setBackgroundColor(color);
            } else {
                viewBg.setBackgroundColor(Color.WHITE);
            }
        } else if (lore_id > 0) {
            viewBg.setBackgroundColor(color);
            helper.setText(R.id.tv_last_layer_chapter_dialog, item.getLore_content());
            if (item.isSelect_Lore_id) {
                viewImage.setVisibility(View.VISIBLE);
            } else {
                viewImage.setVisibility(View.INVISIBLE);

            }
        }
    }

}
